//
//  UIView+Extension.swift
//  KPBaseProject
//
//  Created by Kipp Dev on 2018/3/20.
//  Copyright © 2018年 Kipp. All rights reserved.
//

import Foundation
import LYEmptyView

extension UIView {

    //返回该view所在的父view
    func superView<T: UIView>(of: T.Type) -> T? {

        for view in sequence(first: self.superview, next: { $0?.superview }) {
            if let father = view as? T {
                return father
            }
        }
        return nil
    }

    var right:CGFloat {
        return frame.origin.x + frame.size.width
    }

    var bottom:CGFloat {
        return frame.origin.y + frame.size.height
    }
}

// MARK: - 空页便利方法
public func k_emptyView(emptyImage: String? = "空页",titleStr: String? = "无数据",detailStr: String? = "",btnTitleStr:String? = "重新加载",target: Any,selector:Selector) -> LYEmptyView {
    let empty = LYEmptyView.emptyActionView(withImageStr: emptyImage, titleStr: titleStr, detailStr: detailStr, btnTitleStr: btnTitleStr, target: target, action: selector)
    empty?.actionBtnBackGroundColor = mainColor
    empty?.actionBtnTitleColor = .white
    return empty!
}
